// Copyright tang.  All rights reserved.
// https://gitee.com/inrgihc/dbswitch
//
// Use of this source code is governed by a BSD-style license
//
// Author: tang (inrgihc@126.com)
// Date : 2020/1/2
// Location: beijing , china
/////////////////////////////////////////////////////////////
package middle.ground.entity;


import lombok.Data;
import lombok.NoArgsConstructor;
import middle.ground.dbswitch.common.entity.PatternMapper;
import middle.ground.handler.ListPatternHandler;
import middle.ground.handler.ListTypeHandler;
import tk.mybatis.mapper.annotation.ColumnType;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.List;

@NoArgsConstructor
@Data
@Entity
@Table(name = "DBSWITCH_ASSIGNMENT_CONFIG")
public class AssignmentConfigEntity {

	@Id
	@KeySql(useGeneratedKeys = true)
	@Column(name = "id", insertable = false, updatable = false)
	private Long id;

	@Column(name = "assignment_id")
	private Long assignmentId;

	@Column(name = "source_connection_id")
	private Long sourceConnectionId;

	@Column(name = "source_schema")
	private String sourceSchema;

	@Column(name = "source_tables")
	@ColumnType(typeHandler = ListTypeHandler.class)
	private List<String> sourceTables;

	@Column(name = "excluded")
	private Boolean excluded;

	@Column(name = "target_connection_id")
	private Long targetConnectionId;

	@Column(name = "target_schema")
	private String targetSchema;

	@Column(name = "table_name_map")
	@ColumnType(typeHandler = ListPatternHandler.class)
	private List<PatternMapper> tableNameMap;

	@Column(name = "column_name_map")
	@ColumnType(typeHandler = ListPatternHandler.class)
	private List<PatternMapper> columnNameMap;

	@Column(name = "target_drop_table")
	private Boolean targetDropTable;

	@Column(name = "target_only_create")
	private Boolean targetOnlyCreate;

	@Column(name = "target_sync_exit")
	private Boolean targetSyncExit;

	@Column(name = "target_index_create")
	private Boolean targetIndexCreate;

	@Column(name = "target_lower_case")
	private Boolean targetLowerCase;

	@Column(name = "target_upper_case")
	private Boolean targetUpperCase;

	@Column(name = "target_auto_increment")
	private Boolean targetAutoIncrement;

	@Column(name = "target_data_sync")
	private Boolean targetDataSync;

	@Column(name = "batch_size")
	private Integer batchSize;

	@Column(name = "first_flag")
	private Boolean firstFlag;

	@Column(name = "create_time", insertable = false, updatable = false)
	private Timestamp createTime;
}
